package com.lolc.ihm.component;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.border.LineBorder;

import com.lolc.ihm.Constants;
import com.lolc.utils.Constant;


public class EnnemyTeamBox  extends Box{

	private List<EnnemyPlayerBox> enmemylayerBoxes;
	
	//private List<JComboBox<ComboBoxItem>> championsCBlist;
	
	private BannedChampionsBox bannedChampionBox;
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public EnnemyTeamBox(int axis) {
		super(axis);
		//this.championsCBlist=new ArrayList<JComboBox<ComboBoxItem>>();
		this.enmemylayerBoxes= new ArrayList<EnnemyPlayerBox>();
	}
	
	public void initComponent()
	{
		this.setBounds(Constants.ENNEMY_TEAM_BOX_X, Constants.TEAM_BOX_Y,  Constants.ENNEMY_TEAM_WIDTH, Constants.ENNEMY_TEAM_HEIGHT);
		
		//Title
		JLabel lblEnnemyTeam = new JLabel(Constants.ENNEMY_TEAM_TITLE);
		lblEnnemyTeam.setForeground(Color.WHITE);
		lblEnnemyTeam.setAlignmentX(CENTER_ALIGNMENT);
		lblEnnemyTeam.setFont(Constants.TEAM_TITLE_FONT);
		this.add(lblEnnemyTeam);
		
		//Separator between  2 lists
		Component separator = Box.createHorizontalGlue();
		separator.setPreferredSize(new Dimension(0,Constants.HORIZONTAL_SEPARATOR_HEIGHT));		
		this.add(separator);
		
		Box mainBox = Box.createVerticalBox();
		this.add(mainBox);
		
		mainBox.setBackground(Constants.COLOR_GRAY_1);
		mainBox.setOpaque(true);
		mainBox.setBorder(new LineBorder(Constants.COLOR_GRAY_2, 2));
				
		//Separator between  2 lists
		Component sep = Box.createHorizontalGlue();
		sep.setPreferredSize(new Dimension(0,Constants.HORIZONTAL_SEPARATOR_HEIGHT));		
		mainBox.add(sep);
		
		//Box players
		for (int i=0;i<Constant.NUMBER_PLAYER_PER_TEAM;i++)
		{
			EnnemyPlayerBox ennemyPlayer = new EnnemyPlayerBox(0,i);
			mainBox.add(ennemyPlayer);
			
			ennemyPlayer.initComponents(i);
			ennemyPlayer.validate();
									
			//Separator between  2 lines
			Component separator2 = Box.createHorizontalGlue();
			separator2.setPreferredSize(new Dimension(0,Constants.VERTICAL_SEPARATOR_WIDTH));
			mainBox.add(separator2);
			
			this.enmemylayerBoxes.add(ennemyPlayer);
		}
		
		//Separator between champions and banned champions
		Component separator3 = Box.createHorizontalGlue();
		separator3.setPreferredSize(new Dimension(0,3*Constants.VERTICAL_SEPARATOR_WIDTH));
		mainBox.add(separator3);
		
		//Banned champions
		Box horizontalBox = Box.createHorizontalBox();			
		mainBox.add(horizontalBox);
		
		//Space before
		Component spaceBefore = Box.createVerticalGlue();
		spaceBefore.setPreferredSize(new Dimension(Constants.ENNEMY_SPACE_BEFORE_AFTER_BANNED_CHAMPIONS_LIST, 0));
		horizontalBox.add(spaceBefore);
					
		bannedChampionBox = new BannedChampionsBox(BoxLayout.Y_AXIS);		
		horizontalBox.add(bannedChampionBox);	
		bannedChampionBox.initComponents(Constants.ENNEMY_TEAM_BOX_X, Constants.TEAM_BOX_HEIGHT+100,Constants.ENNEMY_TEAM_WIDTH, Constants.BANNED_CHAMPIONS_HEIGHT,Constants.ENNEMY_SPACE_BEFORE_AFTER_BANNED_CHAMPIONS_LIST,Constants.GROUP_ENNEMY_BANNED_CHAMPIONS);
		bannedChampionBox.validate();
		
		//Space before
		Component spaceAfter= Box.createVerticalGlue();
		spaceAfter.setPreferredSize(new Dimension(Constants.ENNEMY_SPACE_BEFORE_AFTER_BANNED_CHAMPIONS_LIST, 0));
		horizontalBox.add(spaceAfter);
		
		mainBox.validate();		
		this.validate();		
	}
	
	/**
	 * @return the bannedChampionBox
	 */
	public BannedChampionsBox getBannedChampionBox() {
		return bannedChampionBox;
	}

	/**
	 * @param bannedChampionBox the bannedChampionBox to set
	 */
	public void setBannedChampionBox(BannedChampionsBox bannedChampionBox) {
		this.bannedChampionBox = bannedChampionBox;
	}

	/**
	 * @return the enmemylayerBoxes
	 */
	public List<EnnemyPlayerBox> getEnmemylayerBoxes() {
		return enmemylayerBoxes;
	}

	/**
	 * @param enmemylayerBoxes the enmemylayerBoxes to set
	 */
	public void setEnmemylayerBoxes(List<EnnemyPlayerBox> enmemylayerBoxes) {
		this.enmemylayerBoxes = enmemylayerBoxes;
	}

}
